
<template>
<div>
  <Form ref="basicForm" :model="basicForm" :label-width="120" style="width: 600px;">
    <FormItem label="平台名称" prop="site_name" :rules="[{ required: true, message: '平台名称必填', trigger: 'blur' }]">
      <Input v-model="basicForm.site_name" placeholder="欧克汽车鉴定服务系统"></Input>
    </FormItem>
    <FormItem label="实体店名称" prop="store_name" :rules="[{ required: true, message: '实体店名称必填', trigger: 'blur' }]">
      <Input v-model="basicForm.store_name" placeholder="输入实体店名称"></Input>
    </FormItem>
    <FormItem label="全国服务热线" prop="hotline">
      <Input v-model="basicForm.hotline" placeholder="如：0755-12345678"></Input>
    </FormItem>
    <FormItem>
      <Button type="primary" @click="submitBasicForm('basicForm')" :loading='saveLoading'>保存</Button>
    </FormItem>
  </Form>
</div>
</template>
<script>
  import { saveBasic, getBasicParams } from '@/api/param'

export default {
  data() {
    return {
      saveLoading: false,
      basicForm: {
        id: '',
        site_name: '',
        store_name: '',
        hotline: '',
      }
    }
  },
  created() {
    let t = this
    t.getBasicParamsExcute()
  },
  methods: {
    getBasicParamsExcute() {
      let t = this
      getBasicParams().then(res => {
        t.basicForm.id = res.data.id
        t.basicForm.site_name = res.data.site_name
        t.basicForm.store_name = res.data.store_name
        t.basicForm.hotline = res.data.hotline
      })
    },
    submitBasicForm(name) {
      let t = this;
      t.$refs[name].validate((valid) => {
        if (valid) {
          t.saveLoading = true
          saveBasic(t.basicForm).then(res => {
            t.saveLoading = false
            t.$Notice.success({
              title: res.message
            })
          }, function(error) {
            t.saveLoading = false;
          })
        }
      })
    },
  }
}
</script>
